import request from '@/utils/request'

export default {
  getUserList(searchModel) {
    return request({
      url: '/user/list',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        username: searchModel.username,
        phone: searchModel.phone
      }
    })
  },
  addUser(data) {
    return request({
      url: '/user',
      method: 'post',
      data
    })
  },
  editUser(data) {
    return request({
      url: '/user',
      method: 'put',
      data
    })
  },
  saveUser(data) {
    if (data.id == null || data.id === undefined) {
      return this.addUser(data)
    }
    return this.editUser(data)
  },
  getUserInfo(id) {
    return request({
      url: '/user/' + id,
      method: 'get'
    })
  },
  deleteUser(id) {
    return request({
      url: '/user/' + id,
      method: 'delete'
    })
  }
}
